<?php
namespace Admin\Controller;
use Think\Controller;

class DesignController extends Controller
{
	public function index()
	{
		$connect = M('article');
		$count = $connect->where('article_state=1')->count();
		$page = new \Think\Page($count, 10);
		$show = $page->show();
		$article = $connect->where('article_state=1')->order('article_create_time')->limit($page->firstRow.','.$page->listRows)->select();
		$this->assign('article', $article);
		$this->assign('page', $show);
		$this->display();
	}

	public function del()
	{
		// $id = $_GET['id'];
		$id = I('get.id');
		$User = M("article"); // 实例化User对象
		$del = $User->where("article_id=$id")->delete();
		if($del){
    //设置成功后跳转页面的地址，默认的返回页面是$_SERVER['HTTP_REFERER']
			$this->success('删除成功',U('index'),3);
		} else {
    //错误页面的默认跳转页面是返回前一页，通常不需要设置
			$this->error('删除失败');
		}
	}

	public function updata()
	{
		if($id = I('get.id')){
			echo $id;die;
		}
		$this->display();
	}
}